import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author dreamcatcher
 * @date 2022/3/2 21:30
 * 验证URL
 */
public class RegExp10 {
    public static void main(String[] args) {
        String url = "https://www.bilibili.com/video/BV1Eq4y1E79W?p=17&spm_id_from=pageDriver";
        String regex = "^((http|https)://)([\\w-]+\\.)+[\\w]+([\\w/_=?%&#.]*)?$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(url);
        if (matcher.find()){
            System.out.println("该链接是URL");
        }else {
            System.out.println("该链接不是URL");
        }
    }
}
